﻿using MyTodo.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace MyTodo.ViewModels
{
    public class NotebookPlusViewViewModel : BindableBase
    {
        private bool isRightDrawerOpen;
        public DelegateCommand OpenRightDrawerCommand { get; private set; }
        private ObservableCollection<MemorDto> memorDtos;

        public NotebookPlusViewViewModel()
        {
            OpenRightDrawerCommand = new DelegateCommand(OpenRightDrawer);
            MemorDtos = CreateTodos();
        }

        private ObservableCollection<MemorDto> CreateTodos()
        {
            var memorDtos = new ObservableCollection<MemorDto>();
            for (int i = 0; i < 20; i++)
            {
                MemorDto memorDto = new MemorDto();
                memorDto.Title = $"第{i}待办";
                memorDto.Description = $"哇啦哇啦....";
                memorDtos.Add(memorDto);
            }

            return memorDtos;
        }

        private void OpenRightDrawer()
        {
            IsRightDrawerOpen = !IsRightDrawerOpen;
        }

        public bool IsRightDrawerOpen
        {
            get { return isRightDrawerOpen; }
            set
            {
                isRightDrawerOpen = value;
                RaisePropertyChanged();
            }
        }

        public ObservableCollection<MemorDto> MemorDtos
        {
            get { return memorDtos; }
            set
            {
                memorDtos = value;
                RaisePropertyChanged();
            }
        }
    }
}
